﻿// JavaScript Document
	var huameiV3 = {
		init: function() {
		var _this = this;
		_this.searchItems();
	},
/*顶部搜索框下拉列表*/
	searchItems: function() {
		function itemFun() {
			this.items = {};
		};
		itemFun.prototype = {
			// body...
			add: function(id, iArray) {
				this.items[id] = iArray;
			},
			exist: function(id) {
				if (typeof(this.items[id]) == "undefined") return false;
				return true;
			}
		};
		/*初始化下拉数据*/
		var itemsObj1 = new itemFun();
		//选择医生
		itemsObj1.add("0", [{
			src: "/html/doctor/",
				txt: '>眼部塑美医生'
			}, {
				src: "/html/doctor/",
				txt: '>鼻部塑美医生'
			}, {
				src: "/html/doctor/",
				txt: '>胸部塑美医生'
			}, {
				src: "/html/doctor/",
				txt: '>瘦身塑形医生'
			},{
				src: "/html/doctor/",
				txt: '>面部塑形医生'
			}, {
				src: "/html/doctor/",
				txt: '>紧肤除皱医生'
			}, {
				src: "/html/doctor/",
				txt: '>美肤祛斑医生'
			}, {
				src: "/html/doctor/",
				txt: '>韩式纹绣医生'
			}, {
				src: "/html/doctor/",
				txt: '>祛痘美肤医生'
			}, {
				src: "/html/doctor/",
				txt: '>光滑脱毛医生'
			}, {
				src: "/html/doctor/",
				txt: '>美白嫩肤医生'
			}, {
				src: "/html/doctor/",
				txt: '>疤痕修复医生'
			}, {
				src: "/html/doctor/",
				txt: '>中医美容医生'
			}, {
				src: "/html/doctor/",
				txt: '>活力齿科医生'
			}]);
//选择项目
		itemsObj1.add("0_11", [{
				src: "/html/eye/",
				txt: '>眼部塑美'
			}, {
				src: "/html/nose/",
				txt: '>鼻部塑美'
			}, {
				src: "/html/chest/",
				txt: '>胸部塑美'
			}, {
				src: "/html/fubuxz/",
				txt: '>瘦身塑形'
			}, {
				src: "/html/face/",
				txt: '>面部塑形'
			}, {
				src: "/html/jfucz/",
				txt: '>紧肤除皱'
			}, {
				src: "/html/macules/",
				txt: '>美肤祛斑'
			}, {
				src: "/html/wenxiu/",
				txt: '>韩式纹绣'
			}, {
				src: "/html/pox/",
				txt: '>祛痘美肤'
			}, {
				src: "/html/hair/",
				txt: '>光滑脱毛'
			}, {
				src: "/html/mfuzx/",
				txt: '>美白嫩肤'
			}, {
				src: "/html/scar/",
				txt: '>疤痕修复'
			}, {
				src: "#",
				txt: '>中医美容'
			}, {
				src: "#",
				txt: '>活力齿科'
			}
		]);
		//console.log(itemsObj.items);
		var isOpen = false,
			/*默认一级菜单未加载，将不能直接出发二级下拉列表加载*/
			hasLink = false,
			/*下拉菜单是否包含链接*/
			hasNextSelect = false,
			parentActiveIndex = 0,
			tempName = "0"; /*是否还有下一级下拉列表*/
		/*parseUlLists下拉列表数据填充*/

		function parseUlLists(obj, arrIndex, itemJson,hasLink) {
			var elementsStr = "";
			var dataSoure = itemJson.items[arrIndex];
			var ininLen = dataSoure.length;
			for (var i = 0; i < ininLen; i++) {
				if (hasLink) {
					elementsStr += "<li><a href='javascript:void(0)' data-src='" + dataSoure[i].src + "'>" + dataSoure[i].txt + "</a></li>";
				} else {
					elementsStr += "<li><a href='javascript:void(0)'>" + dataSoure[i] + "</a></li>";
				}

			}
			var dataDropLists = obj;
			dataDropLists.empty().append(elementsStr).css({
				position: "absolute",
				left: 0,
				top: dataDropLists.parent().height() + "px",
				width: 210 + 'px'
			});

		};

		$(".keywordSelect i").on("mouseover",function(){
	
				var _self = $(this);
				var hasLink = true;
				var obj = $(this).siblings("ul");
				parseUlLists(obj, '0_11', itemsObj1,hasLink);
				obj.stop().slideToggle(600);
				obj.find("li").each(function(index, element) {
				$(this).click(function(e) {
					if(hasLink){
							_self.attr("data-src", $(this).find("a").attr("data-src"));
						}
					_self.text($(this).text());
					obj.stop().slideUp(600);
				});
			});		
			});	
			
			$(".keywordSelect b").on("mouseover",function(){
	
				var _self = $(this);
				var hasLink = true;
				var obj = $(this).siblings("ul");
				parseUlLists(obj, '0', itemsObj1,hasLink);
				obj.stop().slideToggle(600);
				obj.find("li").each(function(index, element) {
				$(this).click(function(e) {
					if(hasLink){
							_self.attr("data-src", $(this).find("a").attr("data-src"));
						}
					_self.text($(this).text());
					obj.stop().slideUp(600);
				});
			});		
			});				

		$(".keywordSelect .bt").on("click", function() {
			$(this).attr({
				"href": $(".keywordSelect i").attr("data-src"),
				"target": "_blank"
			});
		});
		
		$(".keywordSelect .bt1").on("click", function() {
			$(this).attr({
				"href": $(".keywordSelect b").attr("data-src"),
				"target": "_blank"
			});
		});		

		$(".keywordSelect ul li").each(function(index, element) {
            $(this).click(function(e) {
                alert($(this).index());
            });
        });
		$(".item3 ,.keywordSelect ").mouseleave(function(e) {
                $(this).find("ul").slideUp();
            });
	}	
	
	}	 
$(function() {huameiV3.init();});
//顶部城市箭头20160325
$(function(){
	(function(){
	  var oA = $('.scrollbox').find('a');
	  var oW = oA.width();
	  var aW =oA.length*oW;
	  var num = 0;
	  $('.scrollbox').css({width:aW+'px'});
	  $('.obtn').click(function(){
		  num++;
		  if(num>3) num=0;
		  $('.scrollbox').stop().animate({left:-num*250});
	  });
	})();
})